 

package com.zdkj.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.admin.api.entity.SwStNoticMessage;
import com.zdkj.admin.service.SwStNoticMessageService;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * 通知内容表
 *
 * @author zdkj code generator
 * @date 2020-05-12 17:33:55
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstnoticmessage" )
@Api(value = "swstnoticmessage", tags = "通知内容表管理")
public class SwStNoticMessageController {

    private final  SwStNoticMessageService swStNoticMessageService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStNoticMessage 通知内容表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStNoticMessagePage(Page page, SwStNoticMessage swStNoticMessage) {
        return R.ok(swStNoticMessageService.page(page, Wrappers.query(swStNoticMessage)));
    }


    /**
     * 通过id查询通知内容表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStNoticMessageService.getById(id));
    }

    /**
     * 新增通知内容表
     * @param swStNoticMessage 通知内容表
     * @return R
     */
    @ApiOperation(value = "新增通知内容表", notes = "新增通知内容表")
    @SysLog("新增通知内容表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('admin_swstnoticmessage_add')" )
    public R save(@RequestBody SwStNoticMessage swStNoticMessage) {
        return R.ok(swStNoticMessageService.save(swStNoticMessage));
    }

    /**
     * 修改通知内容表
     * @param swStNoticMessage 通知内容表
     * @return R
     */
    @ApiOperation(value = "修改通知内容表", notes = "修改通知内容表")
    @SysLog("修改通知内容表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_swstnoticmessage_edit')" )
    public R updateById(@RequestBody SwStNoticMessage swStNoticMessage) {
        return R.ok(swStNoticMessageService.updateById(swStNoticMessage));
    }

    /**
     * 通过id删除通知内容表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除通知内容表", notes = "通过id删除通知内容表")
    @SysLog("通过id删除通知内容表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('admin_swstnoticmessage_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStNoticMessageService.removeById(id));
    }

}
